import request from '@/utils/request'

/* 1.账簿 */

// 新增账簿
export function addAccountBook(data) {
  return request({
    url: '/accountBook/create',
    method: 'post',
    data: data
  })
}

// 获取账簿列表
export function listAccountBook(query) {
  return request({
    url: '/accountBook/list',
    method: 'get',
    params: query
  })
}

// 删除账簿
export function delAccountBook(data) {
  return request({
    url: '/accountBook/delete',
    method: 'post',
    data: data
  })
}

/* 2.账单 */

// 查询一级分类
export function searchFirstCategory(data) {
  return request({
    url: '/test01/billCategory/listFirstCategory',
    method: 'post',
    data: data
  })
}
// 查询二级分类
export function searchSecondCategory(data) {
  return request({
    url: '/test01/billCategory/listSecondCategory',
    method: 'post',
    data: data
  })
}

/* 3.账单分类 */

// 查询分类列表
export function listBillCategory(data) {
  return request({
    url: '/test01/billCategory/list',
    method: 'get',
    params: data
  })
}
// 新增分类
export function addBillCategory(data) {
  return request({
    url: '/test01/billCategory/create',
    method: 'post',
    data: data
  })
}
// 删除分类列表
export function delBillCategory(data) {
  return request({
    url: '/test01/billCategory/delete',
    method: 'post',
    data: data
  })
}

/* 4.统计 */

// 获取最新账单的年月日
export function getNewestBill() {
  return request({
    url: '/bill/getNewestBill',
    method: 'get'
  })
}

// 按月份查询支出、收入
export function getAmountByMonth(data) {
  return request({
    url: '/billSummary/getAmountByMonth',
    method: 'post',
    data: data
  })
}
// 按月份获取支出列表
export function getMoneyTop(data) {
  return request({
    url: '/billSummary/getMoneyTop',
    method: 'post',
    data: data
  })
}
// 按月份获取收入列表
export function deleteBillSummary(data) {
  return request({
    url: '/billSummary/delete',
    method: 'post',
    data: data
  })
}
// 查询一级分类
export function listFirstCategory(data) {
  return request({
    url: '/billSummary/listFirstCategory',
    method: 'post',
    data: data
  })
}
// 查询二级分类
export function listSecondCategory(data) {
  return request({
    url: '/billSummary/listSecondCategory',
    method: 'post',
    data: data
  })
}

// 查询记账列表
export function listBill(query) {
  return request({
    url: '/bill/list',
    method: 'get',
    params: query
  })
}
// 新增记账列表
export function addBill(data) {
  return request({
    url: '/bill/create',
    method: 'post',
    data: data
  })
}
// 删除记账列表
export function delBill(data) {
  return request({
    url: '/bill/delete',
    method: 'post',
    data: data
  })
}
